---
layout: "default"
title: "SinkType"
description: "Swift documentation for 'SinkType': Instances of conforming types are effectively functions with the."
keywords: "SinkType,protocol,swift,documentation,put,Element"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">protocol SinkType</code></div>

<div class="discussion comment">
    <p>Instances of conforming types are effectively functions with the
signature <code>(Element) -&gt; Void</code>.</p>

<p>Useful mainly when the optimizer&#39;s ability to specialize generics
outstrips its ability to specialize ordinary closures.  For
example, you may find that instead of:</p>

<pre><code class="language-swift">func f(g: (X)-&gt;Void) { ... g(a) ...}</code></pre>

<p>the following generates better code:</p>

<pre><code class="language-swift">func f&lt;T: Sink where T.Element == X&gt;(g: T) { ... g.put(a) ...}</code></pre>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Element</code>
<div class="comment">
    <p>The type of element to be written to this sink.</p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>







<h3>Instance Methods</h3>
<div class="declaration" id="func-put_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-put_">mutating func put(<wbr>_:)</a>
     <span class="required">Required</span>    
<div class="comment collapse" id="comment-func-put_"><div class="p">
    <p>Write <code>x</code> to this sink.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">mutating func put(x: Element)</code>
    
    
</div></div>
</div>


